<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
	<div class="wrapper wrapper-content">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-content">
						<div class="col-sm-12">
							<h4>发布新闻</h4>
						</div>
						<form class="form-horizontal m-t" id="signupForm">
							<input id="cid" name="cid" type="hidden">
							<div class="form-group">
								<label class="col-sm-1 control-label">标题：</label>
								<div class="col-sm-4">
									<input id="title" name="title" class="form-control" type="text">
								</div>
								<label class="col-sm-1 control-label">作者：</label>
								<div class="col-sm-4">
									<input id="author" name="author" class="form-control"
										type="text">
								</div>
							</div>
							<div class="form-group">
								<label class="col-sm-1 control-label">新闻摘要：</label>
								<div class="col-sm-4">
									<input id="summary" name="summary" class="form-control"
										type="text">
								</div>
								<label class="col-sm-1 control-label">主图上传：</label>
								<div class="col-sm-4">
								<input type="hidden" value="" id="newsSrc" name="newsSrc">
									<div id="uploader" class="wu-example">
										 新闻主图上传
										<div id="thelist" class="uploader-list"></div>
										<div class="btns">
											<div id="picker">选择文件</div>
										</div>
									</div>
								</div>
							</div>

							<div class="form-group">
								<input id="content" name="content" type="hidden"> <label
									class="col-sm-1 control-label">内容：</label>
								<div class="col-sm-11">
									<div class="ibox-content no-padding">
										<div id="content_sn" class="summernote"></div>
									</div>
								</div>
							</div>
							<div class="text-right form-group">
								<input id="status" name="status" type="hidden"> <a
									class="btn btn-default waves-effect waves-light"
									onclick="returnList()">返回列表</a>
								<button type="button"
									class="btn btn-primary waves-effect waves-light" type="submit">保存文章</button>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>
	</div>
	<div th:include="include::footer"></div>


	<script type="text/javascript" src="/js/appjs/news/bContent/add.js"></script>
	<script th:inline="javascript">
		
		
		var uploader = WebUploader.create({
		    // swf文件路径
		    swf: 'https://cdn.bootcss.com/webuploader/0.1.1/Uploader.swf',
		    
		    auto: true,

		    // 文件接收服务端。
		    server: '/mv/io/uploadnews',

		    // 选择文件的按钮。可选。
		    // 内部根据当前运行是创建，可能是input元素，也可能是flash.
		    pick: '#picker',
		    

		    // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
		    resize: false	    
		});
	     
		
		$("#ctlBtn").click(function () {
		     uploader.upload();
		 });
		
		// 当有文件被添加进队列的时候
		uploader.on( 'fileQueued', function( file ) {
			var $list = $("#thelist");
		    $list.append( '<div id="' + file.id + '" class="item">' +
		        '<h4 class="info">' + file.name + '</h4>' +
		        '<p class="state">等待上传...</p>' +
		    '</div>' );
		});
		
		// 文件上传过程中创建进度条实时显示。
		uploader.on( 'uploadProgress', function( file, percentage ) {
		    var $li = $( '#'+file.id ),
		        $percent = $li.find('.progress .progress-bar');

		    // 避免重复创建
		    if ( !$percent.length ) {
		        $percent = $('<div class="progress progress-striped active">' +
		          '<div class="progress-bar" role="progressbar" style="width: 0%">' +
		          '</div>' +
		        '</div>').appendTo( $li ).find('.progress-bar');
		    }

		    $li.find('p.state').text('上传中');

		    $percent.css( 'width', percentage * 100 + '%' );
		});
		
		
		
		uploader.on( 'uploadSuccess', function( file,response) {
		    $( '#'+file.id ).find('p.state').text('已上传');
		    document.getElementById("newsSrc").value = response.msg;
		    parent.layer.msg("上传成功");
		    
		    
		    
		});

		uploader.on( 'uploadError', function( file,response ) {
		    $( '#'+file.id ).find('p.state').text('已上传');
		    document.getElementById("newsSrc").value = response.msg;
		    parent.layer.msg("上传成功");
		});

		uploader.on( 'uploadComplete', function( file ) {
		    $( '#'+file.id ).find('.progress').fadeOut();
		    
		});
		
		
		
	</script>
</body>
</html>
